<script type="text/javascript">
var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
} 

function replace() {
  http.open("GET", "rpc.php", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('foo').innerHTML = http.responseText;
    }
  }
  http.send(null);
}
</script>

<p><a href="javascript:replace()" onclick="alert('hello');">Replace Text</a></p>

<div id=\"hidelater\"><img src=\"loading.gif\"> Please Wait, loading data...</div>
ob_flush(); flush();

<div id="foo">
  Hello, world!
  
</div>

<script>document.getElementById(\"hidelater\").style.display = 'none';</script>
